<%-- 
    Document   : categories
    Created on : 31-oct-2008, 21:03:48
    Author     : org.@le

--%>

<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <c:if test="${sessionBean.ejbSession.owner==null}" >
            <jsp:forward page="../login.jsp" />
        </c:if>
        <c:if test="${!sessionBean.ejbSession.owner.adminUser}" >
            <jsp:forward page="../user/homeUser.jsp" />
        </c:if>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Admin categories</title>
    </head>
    <body>
        <f:view>
            <a4j:region>
            <h:form>
                <h:panelGrid width="100%">
                    <rich:toolBar style="position:absolute; top: 10px; left: 10px" width="300px">
                        <a href="/site-es/faces/admin/admin.jsp" >Admin panel</a> > 
                        <h:outputText value="Manage categories" />
                    </rich:toolBar>
                </h:panelGrid>
                <h2>Manage posting categories</h2>
                    <a4j:commandButton id="add" image="/images/add2.png" reRender="panel1" >
                        <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                        <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{null}" />
                        <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{false}" />
                        <rich:toolTip direction="top-right" >
                            Add category
                        </rich:toolTip>
                    </a4j:commandButton>
                    
                    <a4j:status>
                        <f:facet name="start">
                            <h:graphicImage  value="/images/ajax_process.gif"/>
                        </f:facet>
                    </a4j:status>
            </h:form>
            <br/>
            <h:form id="panel1">
                <h:messages id="mal1" globalOnly="true"/>
                <rich:panel rendered="#{categorieBean.newCategory}">
                    <div align="right" >
                        <a4j:commandButton id="save" value="Guardar" action="#{categorieBean.save}" type="submit" reRender="panel1, panel0" />
                        <a4j:commandButton id="cancel" value="Cancel" immediate="true" reRender="panel1" >
                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{null}" />
                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{false}" />
                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{false}" />
                        </a4j:commandButton>
                    </div>
                    <br/>
                    <h:panelGrid columns="3" >
                        <h:outputText value="(*) Category's Name: " />
                        <h:inputText id="cn" maxlength="30" requiredMessage="Este campo es requerido." required="true" value="#{categorieBean.categoryName}" />
                        <h:message for="cn" style="color: red" styleClass="errorMessage" />
                        <c:if test="${!categorieBean.editCategory}">
                        <h:outputText value="Belongs to: " />
                        <h:selectOneMenu value="#{categorieBean.belongsTo}" >
                            <f:selectItem itemLabel="Communities" itemValue="1" />
                            <f:selectItem itemLabel="Events" itemValue="2" />
                            <f:selectItem itemLabel="Gigs" itemValue="3" />
                            <f:selectItem itemLabel="Housing" itemValue="4" />
                            <f:selectItem itemLabel="Jobs" itemValue="5" />
                            <f:selectItem itemLabel="Personals" itemValue="6" />
                            <f:selectItem itemLabel="Sales" itemValue="7" />
                            <f:selectItem itemLabel="Services" itemValue="8" />
                        </h:selectOneMenu>
                        <h:outputText value="" />
                        </c:if>
                    </h:panelGrid>
                </rich:panel>
            </h:form>
            <h:form>
                <h:panelGrid id="panel0" columns="3" width="100%">
                    <rich:panelMenu width="300px" mode="ajax">
                        <rich:panelMenuGroup id="communityPanel" style="border-width:0px; background-color: purple;" label="Community" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.communityOpened}" >
                            <c:forEach items="#{adminBean.communityCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add12" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{1}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add21" image="/images/trash.png" action="#{categorieBean.removeCommunityCategory}" reRender="panel1, communityPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false">
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                        <rich:panelMenuGroup id="eventPanel" style="border-width:0px; background-color: purple;" label="Event" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.eventOpened}" >
                            <c:forEach items="#{adminBean.eventCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png">
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add121" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{2}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add211" image="/images/trash.png" action="#{categorieBean.removeEventCategory}" reRender="panel1, eventPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                        <rich:panelMenuGroup id="gigPanel" style="border-width:0px; background-color: purple;" label="Gig" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.gigOpened}" >
                            <c:forEach items="#{adminBean.gigCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1211" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{3}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2111" image="/images/trash.png" action="#{categorieBean.removeGigCategory}" reRender="panel1, gigPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false">
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                    </rich:panelMenu>
                                        
                    <rich:panelMenu width="300px"  mode="none">
                        <rich:panelMenuGroup id="housPanel" style="border-width:0px; background-color: purple;" label="Housing" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.housOpened}" >
                            <c:forEach items="#{adminBean.housCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{4}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2" image="/images/trash.png" action="#{categorieBean.removeHousCategory}" reRender="panel1, housPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                        <rich:panelMenuGroup id="jobPanel" style="border-width:0px; background-color: purple;" label="Job" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.jobOpened}" >
                            <c:forEach items="#{adminBean.jobCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1212" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{5}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2112" image="/images/trash.png" action="#{categorieBean.removeJobCategory}" reRender="panel1, jobPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                        <rich:panelMenuGroup id="personalPanel" style="border-width:0px; background-color: purple;" label="Personal" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.personalOpened}" >
                            <c:forEach items="#{adminBean.personalCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1213" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{6}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2113" image="/images/trash.png" action="#{categorieBean.removePersonalCategory}" reRender="panel1, personalPanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                    </rich:panelMenu>
                    <rich:panelMenu width="300px"  mode="none">
                        <rich:panelMenuGroup id="salePanel" style="border-width:0px; background-color: purple;" label="Sale" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.saleOpened}" >
                            <c:forEach items="#{adminBean.saleCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1214" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{7}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2114" image="/images/trash.png" action="#{categorieBean.removeSaleCategory}" reRender="panel1, salePanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                        <rich:panelMenuGroup id="servicePanel" style="border-width:0px; background-color: purple;" label="Service" iconExpanded="chevronUp" iconCollapsed="chevronDown" expanded="#{categorieBean.serviceOpened}" >
                            <c:forEach items="#{adminBean.serviceCategories}" var="category" >
                                <rich:panelMenuItem style="border-width:0px; background-color: #BAD9FE;" icon="/images/users.png" >
                                    <h:panelGrid columns="5" >
                                        <h:outputText value="#{category.categorie}"/>
                                        <a4j:commandButton id="add1215" image="/images/edit.png" reRender="panel1" onclick="javascript:scroll(0,0)">
                                            <f:setPropertyActionListener target="#{categorieBean.newCategory}" value="#{true}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categoryName}" value="#{category.categorie}" />
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <f:setPropertyActionListener target="#{categorieBean.belongsTo}" value="#{8}" />
                                            <f:setPropertyActionListener target="#{categorieBean.editCategory}" value="#{true}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Edit
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                        <a4j:commandButton id="add2115" image="/images/trash.png" action="#{categorieBean.removeServiceCategory}" reRender="panel1, servicePanel" onclick="if(!confirm('The Categorie will be deleted. Are you sure?'))return false" >
                                            <f:setPropertyActionListener target="#{categorieBean.categorieId}" value="#{category.id}" />
                                            <rich:toolTip direction="bottom-right" >
                                                Delete
                                            </rich:toolTip>
                                        </a4j:commandButton>
                                    </h:panelGrid>
                                </rich:panelMenuItem>
                            </c:forEach>
                        </rich:panelMenuGroup>
                    </rich:panelMenu>
                </h:panelGrid>
            </h:form>
            </a4j:region>
        </f:view>
        
    </body>
</html>
